using MicroMsg.Manager;
using MicroMsg.UI.ImageFilter;
using MicroMsg.UI.Page;
using Microsoft.Phone.Controls;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.UserContrl
{
	public class ImageFilterItem : UserControl
	{
		public delegate void ListItemClick(object sender, object object_0);
		public static DependencyProperty ListItemProperty = DependencyProperty.Register("ItemObject", typeof(FilterSetting), typeof(ImageFilterItem), new PropertyMetadata(null, new PropertyChangedCallback(ImageFilterItem.OnItemPropertyChanged)));
		internal Button btnLayoutRoot;
		internal Border border;
		internal Canvas LayoutItem;
		internal Image imgHead;
		internal DynamicTextBlock txtName;
		private bool _contentLoaded;
		public event ImageFilterItem.ListItemClick ItemClick;
		public FilterSetting ItemObject
		{
			get
			{
				return (FilterSetting)base.GetValue(ImageFilterItem.ListItemProperty);
			}
			set
			{
				base.SetValue(ImageFilterItem.ListItemProperty, value);
			}
		}
		public ImageFilterItem()
		{
			this.InitializeComponent();
			base.SetValue(TiltEffect.IsTiltEnabledProperty, true);
		}
		private static void OnItemPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == ImageFilterItem.ListItemProperty)
			{
				(dependencyObject_0 as ImageFilterItem).OnListItemPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void OnListItemPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			try
			{
				this.RefreshItem(dependencyPropertyChangedEventArgs_0.get_NewValue() as FilterSetting);
			}
			catch (Exception ex)
			{
				ex.ToString();
			}
		}
		public void RefreshItem(FilterSetting item)
		{
			if (item == null)
			{
				return;
			}
			if (R.isEnglish())
			{
				this.txtName.set_FontSize(20.0);
			}
			this.imgHead.set_Source(ImageCacheMgr.loadFromRes(item.icon));
			this.txtName.Text = R.GetStringByKey("Filter_" + item.string_0);
			if (!item.Equals(ImageFilterPage.CurrentFilterType) && (ImageFilterPage.CurrentFilterType != null || !(item.string_0 == "Normal")))
			{
				this.border.set_BorderBrush(R.theme.Filter_Border_Normal_BRUSH);
				this.border.set_Opacity(0.7);
				return;
			}
			ImageFilterPage.CurrentFilterType = item;
			ImageFilterPage.CurrentFilterItem = this;
			this.border.set_BorderBrush(R.theme.Filter_Border_HighLight_BRUSH);
			this.border.set_Opacity(1.0);
		}
		private void btnLayoutRoot_Click(object sender, RoutedEventArgs e)
		{
			if (this.ItemClick != null)
			{
				this.ItemClick(this, this.ItemObject);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/ImageFilter/ImageFilterItem.xaml", 2));
			this.btnLayoutRoot = (Button)base.FindName("btnLayoutRoot");
			this.border = (Border)base.FindName("border");
			this.LayoutItem = (Canvas)base.FindName("LayoutItem");
			this.imgHead = (Image)base.FindName("imgHead");
			this.txtName = (DynamicTextBlock)base.FindName("txtName");
		}
	}
}
